package com.sigmazero13.MKDummy.activites;

import java.util.List;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.sigmazero13.MKDummy.MKDummyPlayerApp;
import com.sigmazero13.MKDummy.listeners.OnTabUnselectedListener;
import com.sigmazero13.MKDummy.models.ReferenceCard;
import com.sigmazero13.MKDummy.utils.ReferenceCardListAdapter;

public class RefCardListFragment extends ListFragment implements OnItemClickListener, OnTabUnselectedListener {

	public RefCardListFragment() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);	
		List<ReferenceCard> cards = ((MKDummyPlayerApp)getActivity().getApplication()).getReferenceCards();
		ReferenceCardListAdapter adapter = new ReferenceCardListAdapter(getActivity(), android.R.layout.simple_list_item_1, cards);
		setListAdapter(adapter);
		getListView().setOnItemClickListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		ReferenceCard card = (ReferenceCard)parent.getItemAtPosition(position);
		((MKDummyPlayerActivity)getActivity()).selectReferenceCard(card);
	}
	
	@Override
	public void onTabUnselected() {
		// DO NOTHING
	}
	
}
